package com.tian.core.entity;

import java.util.Comparator;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.OneToMany;

import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.Table;

import org.apache.struts2.json.annotations.JSON;




/**
 * Ztree entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "ztree", catalog = "portalservermond")
public class Ztree implements java.io.Serializable,Comparable<Ztree>{

	// Fields

	private Integer id;
	private String groupname;
	private String icon;
	private String name;
	private Boolean open;
	private String url;
	private Integer pId;
	private String iconOpen;
	private String iconClose;
	private String target;
	private Boolean checked;
	private Set<Ztreegroup> ztreegroups = new HashSet<Ztreegroup>(0);
	private Set<Operbutton> operbuttons = new HashSet<Operbutton>(0);
	// Constructors

	/** default constructor */
	public Ztree() {
	}

	/** minimal constructor */
	public Ztree(String name, Boolean open, String url) {
		this.name = name;
		this.open = open;
		this.url = url;
	}

	/** full constructor */
	public Ztree(String icon, String name, Boolean open,
			String url, Integer pId, String iconOpen, String iconClose,
			String target) {
		this.icon = icon;
		this.name = name;
		this.open = open;
		this.url = url;
		this.pId = pId;
		this.iconOpen = iconOpen;
		this.iconClose = iconClose;
		this.target = target;
	}

	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@Column(name = "icon", length = 100)
	public String getIcon() {
		return this.icon;
	}

	public void setIcon(String icon) {
		this.icon = icon;
	}

	@Column(name = "name", nullable = false, length = 100)
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "open", nullable = false)
	public Boolean getOpen() {
		return this.open;
	}

	public void setOpen(Boolean open) {
		this.open = open;
	}
	@Column(name = "checked", nullable = false)
	public Boolean getChecked() {
		return checked;
	}

	public void setChecked(Boolean checked) {
		this.checked = checked;
	}

	@Column(name = "url", nullable = false, length = 100)
	public String getUrl() {
		return this.url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	@Column(name = "pId")
	public Integer getpId() {
		return this.pId;
	}

	public void setpId(Integer pId) {
		this.pId = pId;
	}

	@Column(name = "iconOpen", length = 100)
	public String getIconOpen() {
		return this.iconOpen;
	}

	public void setIconOpen(String iconOpen) {
		this.iconOpen = iconOpen;
	}

	@Column(name = "iconClose", length = 100)
	public String getIconClose() {
		return this.iconClose;
	}

	public void setIconClose(String iconClose) {
		this.iconClose = iconClose;
	}

	@Column(name = "target", length = 100)
	public String getTarget() {
		return this.target;
	}

	public void setTarget(String target) {
		this.target = target;
	}
	@Column(name = "groupname", length = 100)
	public String getGroupname() {
		return groupname;
	}

	public void setGroupname(String groupname) {
		this.groupname = groupname;
	}

	@JSON(serialize=false)
	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "ztree")
	public Set<Ztreegroup> getZtreegroups() {
		return this.ztreegroups;
	}

	public void setZtreegroups(Set<Ztreegroup> ztreegroups) {
		this.ztreegroups = ztreegroups;
	}
	@JSON(serialize=false)
	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy = "ztree")
	public Set<Operbutton> getOperbuttons() {
		return this.operbuttons;
	}

	public void setOperbuttons(Set<Operbutton> operbuttons) {
		this.operbuttons = operbuttons;
	}

	@Override
	public int compareTo(Ztree o) {
		return this.getId().compareTo(o.getId());
		
	}

}